﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KingSite.Shop.Domain.ShowDataModel {

    #region ShoppingCartModel

    public class CartItem : CartDetail {
        public decimal ItemSubTotal {
            get {
                return SellingPrice * Quantity;
            }
        }
        public string ItemName { get; set; }
    }

    public class ShoppingCartItems : SortedList<int, CartItem> {
        public ShoppingCartItems Sort() {
            IList<int> KeyList = this.Keys;
            for (int i = 0; i < KeyList.Count - 1; i++) {
                for (int j = i + 1; j < KeyList.Count; j++) {
                    int tmpi = KeyList[i];
                    int tmpj = KeyList[j];
                    if (this[tmpj].Id > this[tmpi].Id) {
                        CartItem item = this[tmpi];
                        this[tmpi] = this[tmpj];
                        this[tmpj] = item;
                    }
                }
            }
            return this;
        }

    }

    #endregion
}
